package com.huangwei.controller;

import com.huangwei.model.SaleServiceShop;
import com.huangwei.service.CarBandService;
import com.huangwei.service.CarService;
import com.huangwei.service.SaleServiceShopService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/saleServiceShop")
public class SaleServiceShopController {
    @Resource
    SaleServiceShopService saleServiceShopService;
    @Resource
    CarService carService;

    @GetMapping("/getSaleServiceShopList")
    public List getSaleServiceShopList() {
        return saleServiceShopService.getSaleServiceShopList();
    }

    @GetMapping("/getOneSaleServiceShop")
    public SaleServiceShop getOneSaleServiceShop(HttpServletRequest request) {
        Map<String, String[]> map = request.getParameterMap();
        return saleServiceShopService.
                getOneSaleServiceShopById(Integer.parseInt(map.get("shopId")[0]));
    }

    @GetMapping("/getCars")
    public List getCarsByShop(HttpServletRequest request) {
        Map<String, String[]> map = request.getParameterMap();
        return carService.getCarsBySaleServiceShop(Integer.parseInt(map.get("shopId")[0]));
    }
}
